import { contextBridge, ipcRenderer } from 'electron';
console.log('preload.ts 加载了');
contextBridge.exposeInMainWorld('electronAPI', {
  selectDirectory: () => ipcRenderer.invoke('select-directory'),
  getMovieList: (dirPath: string) => ipcRenderer.invoke('get-movie-list', dirPath),
  searchMovies: (query: string) => ipcRenderer.invoke('search-movies', query),
  getMovieDetails: (movieId: number) => ipcRenderer.invoke('get-movie-details', movieId),
  downloadImage: (url: string) => ipcRenderer.invoke('download-image', url),
  downloadImageBase64: (url: string) => ipcRenderer.invoke('download-image-base64', url),
  playMovie: (moviePath: string) => ipcRenderer.invoke('play-movie', moviePath),
  getMovieFiles: (movieDir: string) => ipcRenderer.invoke('get-movie-files', movieDir),
  saveMovieDetails: (movieData: any, movieDir: string) => ipcRenderer.invoke('save-movie-details', movieData, movieDir),
  readMovieDetails: (movieDir: string) => ipcRenderer.invoke('read-movie-details', movieDir),
  openExternal: (url) => ipcRenderer.send('open-external', url),
  // 暴露一个用于最小化窗口的函数
  minimizeWindow: () => ipcRenderer.send('minimize-window'),
  // 暴露一个用于切换最大化/恢复的函数
  toggleMaximize: () => ipcRenderer.send('toggle-maximize'),
  // 暴露一个用于关闭窗口的函数
  closeWindow: () => ipcRenderer.send('close-window'),
  openFolder: (dir: string) => ipcRenderer.invoke('open-folder', dir),
  runSubtitleBat: (dir) => ipcRenderer.invoke("run-subtitle-bat", dir),
})